%Solves for L0 such that at time T the inflation anchor piA is on target, equal to pix
c0s(1)=L0;
sol=ode15s(@(t,y) Equi(t,y,rho,g,n,frisch,kL,theta,beta,phi,pix,kW,RefWealth,sigma,NaturalRate,piW),[0 T],[L0;piA0;delta0;0]);
t=sol.x';
y=sol.y';
ec0s(1)=y(end,2)-pix;

if abs(ec0s(1))>10^(-4)
c0s(2)=c0s(1)-0.000000001;
L0=c0s(2);
sol=ode15s(@(t,y) Equi(t,y,rho,g,n,frisch,kL,theta,beta,phi,pix,kW,RefWealth,sigma,NaturalRate,piW),[0 T],[L0;piA0;delta0;0]);
t=sol.x';
y=sol.y';
ec0s(2)=y(end,2)-pix;

while abs(ec0s(2))>10^(-3)
    c0s(3)=c0s(2)-ec0s(2)*(c0s(2)-c0s(1))/(ec0s(2)-ec0s(1));
    ec0s(1)=ec0s(2);
    L0=c0s(3);
    sol=ode15s(@(t,y) Equi(t,y,rho,g,n,frisch,kL,theta,beta,phi,pix,kW,RefWealth,sigma,NaturalRate,piW),[0 T],[L0;piA0;delta0;0]);
    t=sol.x';
    y=sol.y';
    ec0s(2)=y(end,2)-pix;
    c0s(1)=c0s(2);
    c0s(2)=c0s(3);
end
end
